package com.yiyahui.project.erp.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yiyahui.framework.aspectj.lang.annotation.Log;
import com.yiyahui.framework.aspectj.lang.enums.BusinessType;
import com.yiyahui.project.erp.domain.YiyaClinic;
import com.yiyahui.project.erp.service.IYiyaClinicService;
import com.yiyahui.framework.web.controller.BaseController;
import com.yiyahui.framework.web.domain.AjaxResult;
import com.yiyahui.common.utils.poi.ExcelUtil;
import com.yiyahui.framework.web.page.TableDataInfo;

/**
 * 门诊Controller
 * 
 * @author yiyahui
 * @date 2020-05-03
 */
@RestController
@RequestMapping("/erp/clinic")
public class YiyaClinicController extends BaseController
{
    @Autowired
    private IYiyaClinicService yiyaClinicService;

    /**
     * 查询门诊列表
     */
    @PreAuthorize("@ss.hasPermi('erp:clinic:list')")
    @GetMapping("/list")
    public TableDataInfo list(YiyaClinic yiyaClinic)
    {
        startPage();
        List<YiyaClinic> list = yiyaClinicService.selectYiyaClinicList(yiyaClinic);
        return getDataTable(list);
    }

    /**
     * 导出门诊列表
     */
    @PreAuthorize("@ss.hasPermi('erp:clinic:export')")
    @Log(title = "门诊", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(YiyaClinic yiyaClinic)
    {
        List<YiyaClinic> list = yiyaClinicService.selectYiyaClinicList(yiyaClinic);
        ExcelUtil<YiyaClinic> util = new ExcelUtil<YiyaClinic>(YiyaClinic.class);
        return util.exportExcel(list, "clinic");
    }

    /**
     * 获取门诊详细信息
     */
    @PreAuthorize("@ss.hasPermi('erp:clinic:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(yiyaClinicService.selectYiyaClinicById(id));
    }

    /**
     * 新增门诊
     */
    @PreAuthorize("@ss.hasPermi('erp:clinic:add')")
    @Log(title = "门诊", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YiyaClinic yiyaClinic)
    {
        return toAjax(yiyaClinicService.insertYiyaClinic(yiyaClinic));
    }

    /**
     * 修改门诊
     */
    @PreAuthorize("@ss.hasPermi('erp:clinic:edit')")
    @Log(title = "门诊", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YiyaClinic yiyaClinic)
    {
        return toAjax(yiyaClinicService.updateYiyaClinic(yiyaClinic));
    }

    /**
     * 删除门诊
     */
    @PreAuthorize("@ss.hasPermi('erp:clinic:remove')")
    @Log(title = "门诊", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yiyaClinicService.deleteYiyaClinicByIds(ids));
    }
}
